﻿namespace HRM.CORE
{
    using DevExpress.XtraEditors;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;

    public class xfmTimekeeperOverTime : XtraForm
    {
        private IContainer components = null;
        public static HRM.CORE.xucTimekeeperOverTime xucTimekeeperOverTime;

        public event ClosedHandler Closed;

        public event TimekeeperTableDeletedHandler TimekeeperTableDeleted;

        public event TimekeeperTableInsertedHandler TimekeeperTableInserted;

        public event UnShiftDataHandler UnShiftData;

        public xfmTimekeeperOverTime()
        {
            this.InitializeComponent();
            base.Load += new EventHandler(this.xfmTimekeeperOverTime_Load);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x284, 0x1b2);
            base.Name = "xfmTimekeeperOverTime";
            this.Text = "Bảng Chấm C\x00f4ng Tăng Ca Theo Th\x00e1ng";
            base.ResumeLayout(false);
        }

        public void LoadTimekeeperTableList()
        {
            xucTimekeeperOverTime.LoadTimeKeeperTableList();
        }

        private void RaiseClosedHandler()
        {
            if (this.Closed != null)
            {
                this.Closed(this);
            }
        }

        private void RaiseTimekeeperTableDeletedHander()
        {
            if (this.TimekeeperTableDeleted != null)
            {
                this.TimekeeperTableDeleted(this);
            }
        }

        private void RaiseTimekeeperTableInsertedHander()
        {
            if (this.TimekeeperTableInserted != null)
            {
                this.TimekeeperTableInserted(this);
            }
        }

        private void RaiseUnShiftDataHandler(int Month, int Year)
        {
            if (this.UnShiftData != null)
            {
                this.UnShiftData(this, Month, Year);
            }
        }

        public void SaveBeforeClose()
        {
            if (((xucTimekeeperOverTime.dt_Timekeeper.Rows.Count > 0) && (XtraMessageBox.Show("Bạn c\x00f3 muốn lưu lại dữ liệu đ\x00e3 thay đổi kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No)) && !xucTimekeeperOverTime.SaveData())
            {
                XtraMessageBox.Show("Lưu thất bại!");
            }
        }

        private void xfmTimekeeperOverTime_Load(object sender, EventArgs e)
        {
            xucTimekeeperOverTime = new HRM.CORE.xucTimekeeperOverTime();
            xucTimekeeperOverTime.Closed += new HRM.CORE.xucTimekeeperOverTime.ClosedHandler(this.xucTimekeeperOverTime_Closed);
            xucTimekeeperOverTime.UnShiftData += (s, m, y) => this.RaiseUnShiftDataHandler(m, y);
            xucTimekeeperOverTime.TimekeeperTableDeleted += s => this.RaiseTimekeeperTableDeletedHander();
            xucTimekeeperOverTime.Dock = DockStyle.Fill;
            base.Controls.Add(xucTimekeeperOverTime);
        }

        private void xucTimekeeperOverTime_Closed(object sender)
        {
            base.Close();
        }

        public delegate void ClosedHandler(object sender);

        public delegate void TimekeeperTableDeletedHandler(object sender);

        public delegate void TimekeeperTableInsertedHandler(object sender);

        public delegate void UnShiftDataHandler(object sender, int Month, int Year);
    }
}

